<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class M_instansi extends CI_Controller {

	function __construct() {
        parent::__construct();	
		$this->load->model("master/master_instansi"); 		
	}
	
	function index()
	{
		$data['judul'] = "Master Instansi";
		$data['list'] = $this->master_instansi->read();
		$data['main_view']='master/instansi/instansi';
		$this->load->view('index',$data);
		
	}

	function save()
	{
		$dataInsert = array(
			'instansi' => $this->input->post('instansi'),
			'alamat' => $this->input->post('alamat'),
			'email' => $this->input->post('email'),
			'no_tlp' => $this->input->post('no_tlp'),
			'site' => $this->input->post('site')
		);
		$this->master_instansi->save($dataInsert);
	}

	function edit()
	{
		$id_m_instansi = $this->input->post('id_m_instansi');
		$data['list']=$this->master_instansi->edit($id_m_instansi);	
		$this->load->view('master/instansi/edit',$data);
	}
	
	function update()
	{	
		$id_m_instansi=$this->input->post('id_m_instansi');
		$dataUpdate=array(
			'instansi'=>$this->input->post('instansi'),
			'alamat' => $this->input->post('alamat'),
			'email' => $this->input->post('email'),
			'no_tlp' => $this->input->post('no_tlp'),
			'site' => $this->input->post('site')
		);		
		$this->master_instansi->update($id_m_instansi,$dataUpdate);
	}
	
	function delete()
	{
		$id_m_instansi = $this->input->post('id_m_instansi');
		$this->master_instansi->delete($id_m_instansi);
	}
	
	function refresh()
	{
		$data['list'] = $this->master_instansi->read();
		$this->load->view('master/instansi/refresh', $data);
		
	}

	function detail()
	{
		$id_m_instansi = $this->input->post('id_m_instansi');
		$data['list']=$this->master_instansi->edit($id_m_instansi);	
		$this->load->view('master/instansi/detail',$data);
	}
	
}